{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <select name="type" class="layui-input">
                                <option value="">类型</option>
                                <option value="1" {if !empty(input('get.type')) && input('get.type')==1}selected{/if}>
                                    关于我们
                                </option>
                                <option value="2" {if !empty(input('get.type')) && input('get.type')==2}selected{/if}>
                                    免责说明
                                </option>
                                <option value="3" {if !empty(input('get.type')) && input('get.type')==3}selected{/if}>
                                    规则与协议
                                </option>
                                <option value="4" {if !empty(input('get.type')) && input('get.type')==4}selected{/if}>
                                    在线学习
                                </option>
                                <option value="5" {if !empty(input('get.type')) && input('get.type')==5}selected{/if}>
                                    招募合伙人
                                </option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="title" placeholder="文本名称" value="{:input('get.title')}"
                                autocomplete="off" class="layui-input">
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="sreach">搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn layui-btn-sm" onclick="data_edit('添加','news_add')"><i
                            class="layui-icon">&#xe654;</i>添加</button>&nbsp;
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form" lay-size="sm">
                        <thead>
                            <tr>
                                <th width="50">ID</div></th>
                                <th width="200">标题</div></th>
                                <th width="150">客户端</div></th>
                                <th width="100">日期</div></th>
                                <th width="200">发布时间</div></th>
                                <th width="300">操作</div></th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td><div class="layui-table-cell">{$v.id|default='0'}</div></td>
                                <td><div class="layui-table-cell">{$v.title|default=''}</div></td>
                                <td><div class="layui-table-cell">
                                    {if $v.type == 1}
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn layui-btn-sm-sm  layui-btn layui-btn-sm">关于我们</button>
                                    {elseif $v.type == 2}
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn layui-btn-sm-sm  layui-btn layui-btn-sm">免责说明</button>
                                    {elseif $v.type == 3}
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn layui-btn-sm-sm  layui-btn layui-btn-sm">规则与协议</button>
                                    {elseif $v.type == 4}
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn layui-btn-sm-sm  layui-btn layui-btn-sm">在线学习</button>
                                    {elseif $v.type == 5}
                                    <button type="button" class="layui-btn layui-btn-sm layui-btn layui-btn-sm-sm  layui-btn layui-btn-sm">招募合伙人</button>
                                    {/if}
                                </div></td>
                                <td><div class="layui-table-cell">{$v.dates|default=''}</div></td>
                                <td><div class="layui-table-cell">{$v.created|default=''}</div></td>
                                <td class="td-manage">
                                    <a title="编辑" onclick="data_edit('编辑','/system/news_add?id={$v.id}')"
                                        href="javascript:;" class="layui-btn layui-btn-sm">
                                        编辑
                                    </a>
                                    <a title="删除" onclick="data_del(this,'/system/news_del','{$v.id}')"
                                        href="javascript:;" class="layui-btn layui-btn-sm-danger layui-btn layui-btn-sm">
                                        <i class="layui-icon">&#xe640;</i>
                                    </a>
                                </div></td>

                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['upload', 'form'], function () {
        var $ = layui.jquery
            , upload = layui.upload;
        //图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: 'users_top'
            , accept: 'file'
            , exts: 'xls|csv'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.status > 0) {
                    return layer.msg(res.msg);
                }
                //上传成功
                return layer.msg(res.msg);
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-sm layui-btn layui-btn-sm-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    });
    function showimg(imgs) {
        console.log(imgs);
        layer.open({
            type: 1,
            title: false,
            shadeClose: true,
            skin: 'layui-layer-nobg', //没有背景色
            content: "<img src='" + imgs + "' style='width:100%;height: 100%;'>"
        });
    }
    function orderstr(title, url, id, status) {
        layer.confirm(title, { title: '请谨慎操作' }, function (index) {
            $.post(url, { id: id, status: status }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 1, time: 1000 });
                    location.replace(location.href);
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
</script>
{include file="public/footer"}